module vga_colorbar (
	input						clk_50m, 		//系统时钟50MHz
	input						rst, 			//高电平复位信号
	//VGA接口
	output						vga_hs, 		//行同步信号
	output						vga_vs,			//场同步信号
	output		[11:0]		    vga_rgb			//红绿蓝三原色输出，分为RGB444,RGB565
);
	parameter	H_DISP	= 12'd1600;			    //行有效数据
	parameter	V_DISP	= 12'd900;			    //场有效数据
	parameter	FPS		= 11'd60;			    //帖率，刷新率

	wire		[12:0]	H_SYNC;			    //行同步
	wire		[12:0]	H_BACK;			    //行显示后沿
	wire		[12:0]	H_FRONT;			    //行显示前沿
	wire		[12:0]	H_TOTAL;			    //行扫描周期

	wire		[12:0]	V_SYNC;				//场同步
	wire		[12:0]	V_BACK;			    //场显示后沿
	wire		[12:0]	V_FRONT;				//场显示前沿
	wire		[12:0]	V_TOTAL;			    //场扫描周期

	assign rst_n = ~rst;						//高电平复位信号取反

	//wire define
	wire			vga_clk;
	wire			rst_n_w;
	wire [11:0]	pixel_data_w;					//像素点数据
	wire [12:0]	pixel_xpos_w;					//像素点横坐标
	wire [12:0]	pixel_ypos_w;					//像素点纵坐标

	vga_resolution #(
		.H_DISP				(H_DISP),
		.V_DISP				(V_DISP),
		.FPS				(FPS)
	)
	vga_resolution_inst (
		.clk				(clk_50m),
		.rst_n				(rst_n),

		.H_SYNC				(H_SYNC),
		.H_BACK				(H_BACK),
		.H_FRONT			(H_FRONT),
		.H_TOTAL			(H_TOTAL),

		.V_SYNC				(V_SYNC),
		.V_BACK				(V_BACK),
		.V_FRONT			(V_FRONT),
		.V_TOTAL			(V_TOTAL),
		.vga_clk			(vga_clk),
		.rst_n_w			(rst_n_w)
	);

	vga_driver #(
		.H_DISP				(H_DISP),
		.V_DISP				(V_DISP)
	)
	u_vga_driver
	(
		.vga_clk			(vga_clk),
		.sys_rst_n			(rst_n_w),
		
		.H_SYNC				(H_SYNC),
		.H_BACK				(H_BACK),
		.H_FRONT			(H_FRONT),
		.H_TOTAL			(H_TOTAL),
		
		.V_SYNC				(V_SYNC),
		.V_BACK				(V_BACK),
		.V_FRONT			(V_FRONT),
		.V_TOTAL			(V_TOTAL),
		
		.vga_hs				(vga_hs),
		.vga_vs				(vga_vs),
		.vga_rgb			(vga_rgb),
		
		.pixel_xpos			(pixel_xpos_w),
		.pixel_ypos			(pixel_ypos_w),
		.pixel_data			(pixel_data_w)
	);

	vga_display #(
		.H_DISP				(H_DISP),
		.V_DISP				(V_DISP)
	)
	u_vga_display
	(
		.vga_clk			(vga_clk),
		.sys_rst_n			(rst_n_w),
		
		.pixel_xpos			(pixel_xpos_w),
		.pixel_ypos			(pixel_ypos_w),
		.pixel_data			(pixel_data_w)
	);

endmodule 